package cn.xopencode.appletweb.controller.security.violate;

import cn.xopencode.common.framework.vo.CommonResult;
import cn.xopencode.common.framework.vo.PageResult;
import cn.xopencode.securityservice.rpc.violate.ViolateRpc;
import cn.xopencode.securityservice.rpc.violate.dto.ViolateAuditReqDTO;
import cn.xopencode.securityservice.rpc.violate.dto.ViolateCreateReqDTO;
import cn.xopencode.securityservice.rpc.violate.dto.ViolatePageReqDTO;
import cn.xopencode.securityservice.rpc.violate.dto.ViolateRespDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@Api(tags = "反三违及事故情况 API")
@RestController
@RequestMapping("/violate")
@Validated
public class ViolateActivityController {

    @DubboReference(version = "${dubbo.consumer.ViolateRpc.version}")
    private ViolateRpc violateRpc;

    @ApiOperation(value = "根据ID获得反三违及事故情况")
    @GetMapping("/get/{violateId}")
    public CommonResult<ViolateRespDTO> getViolate(@PathVariable(value="violateId",required=false)String violateId) {
        return violateRpc.getViolate(violateId);
    }
    @PostMapping("/page")
    @ApiOperation("分页获取反三违及事故情况")
    public CommonResult<PageResult<ViolateRespDTO>> pageViolate(ViolatePageReqDTO pageDTO){
        return violateRpc.pageViolate(pageDTO);
    }

    @PostMapping("/add")
    @ApiOperation("新增反三违及事故情况")
    public CommonResult<Integer> createViolate(@Valid ViolateCreateReqDTO createDTO){
        return violateRpc.createViolate(createDTO);
    }
    @PostMapping("/audit")
    @ApiOperation("审核反三违及事故情况")
    public CommonResult<Integer> auditViolate(@Valid ViolateAuditReqDTO reqDTO){
        return violateRpc.auditViolate(reqDTO);
    }

}
